<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>意见箱</title>
</head>
<style>
    tr td {
        max-width: 500px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>
<body class="user-select">
<section class="container-fluid">
    <header th:replace="admin/_fragments :: header">
    </header>
    <div class="row" th:replace="admin/_fragments :: menu(4)">
    </div>
</section>

<div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
    <form action="/Article/checkAll" method="post">
        <h1 class="page-header">管理 <span class="badge" th:text="${Quantity.suggest_num}">7</span></h1>
        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th><span class="glyphicon glyphicon-lock"></span> <span class="visible-lg">ID</span></th>
                    <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">内容</span></th>
                </tr>
                </thead>
                <tbody class="table-striped" th:each="suggest : ${Suggest}">
                <tr>
                    <td onclick="detail(this.id)" th:id="${suggest.id}" class="hidden-sm" id="suggest_id" th:text="${suggest.id}">1</a></td>
                    <td class="hidden-sm" th:text="${suggest.content}">猪猪</a></td>
                </tr>
                </tbody>
            </table>
        </div>
    </form>
</div>

<script src="../../static/js/jquery.js" type="text/javascript" th:src="@{/js/jquery.js}"></script>
<script src="../../static/js/admin-scripts.js" type="text/javascript" th:src="@{/js/admin-scripts.js}"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script src="../../js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>


<script>
    function detail(id) {
        console.log("id="+id);
        // window.location.href = "/suggest/" + id;

    }

    //是否确认删除
    $(function () {
        $("#main table tbody tr td a").click(function () {
            var name = $(this);
            var id = name.attr("rel"); //对应id
            if (event.srcElement.outerText === "删除") {
                if (window.confirm("此操作不可逆，是否确认？")) {
                    $.ajax({
                        type: "POST",
                        url: "/Category/delete",
                        data: "id=" + id,
                        cache: false, //不缓存此页面
                        success: function (data) {
                            window.location.reload();
                        }
                    });
                }

            }

        });
    });


</script>

</body>
</html>
